#include <stdio.h>
#include <stdlib.h>

unsigned long long my_loop_sum(unsigned long long begin, unsigned long long end);
unsigned long long gauss_sum(unsigned long long begin, unsigned long long end);

int main(void) 
{
	printf("%d\n", my_loop_sum(2, 1000));
	printf("%lld\n", my_loop_sum(2, 1000000));
	printf("%lld\n", my_loop_sum(2, 1000000000));
	
	printf("gauss:\n");
	printf("%d\n", gauss_sum(2, 1000));
	printf("%lld\n", gauss_sum(2, 1000000));
	printf("%lld\n", gauss_sum(2, 1000000000));
	return 0;
}

unsigned long long my_loop_sum(unsigned long long begin, unsigned long long end)
{
	unsigned long long result = 0;
	unsigned long long i;
	for(i = begin; i <= end; i+=2)result += i;
	return result;
}

unsigned long long gauss_sum(unsigned long long begin, unsigned long long end)
{
	unsigned long long n = (end - begin) / 2 + 1;
	unsigned long long result = (begin + end) * n / 2;
	return result;
}